#ifndef CAMERA_H
#define CAMERA_H

#define CAMERA (Camera::GetSingleton())

#include <vector>

#include "Vector2df.h"
#include "MapData.h"
#include "HeroClass.h"
#include "Timer.h"

class Camera
{
private:
    Camera();
    static Camera* m_camera;
public:
    ~Camera();
    static Camera* GetSingleton();
    Vector2df getMapOffset() const;
    Vector2df move(Hero* const player);
    void jumpTo(const Vector2df position);
    void centerOnPlayer(const BaseUnit* const player);
    void Shake(CRuint amount=10);
    void Shake(vector<Vector2df> pattern);
    void update();
    int getVisibleTileIndex(const SimpleDirection dir) const;
    int getLogicTileIndex(const SimpleDirection dir) const;
    SDL_Rect getVisibleTileRect() const;    // result is (x,y,width,height)
    SDL_Rect getLogicTileRect() const;    // result is (x,y,width,height)
private:
    Vector2df checkScreenPlayer(const Vector2df position, const Vector2df speed);
    float checkCTiles(const MapData* const data, CRint minX, CRint maxX, CRint minY, CRint maxY, const Vector2df speed);

    Vector2df mapOffset;    // This is used to move the map instead of the player - map offset in pixels
    Vector2df mapSubOffset; // This is used to move the map for shake effects
    uint shakeIndex;
    Timer *shakeTimer; // This is used for shake effects
    vector<Vector2df> shakePattern;
    Vector2df lastPos;

    Vector2df velocity;
};

#endif // CAMERA_H
